package com.jye.cloud.user.controller;



import com.jye.cloud.Constants.MyConstants;
import com.jye.cloud.domain.Like;
import com.jye.cloud.user.service.LikeService;
import com.jye.cloud.domain.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/like")
@Api(tags="点赞控制器API")
public class LikeController {
    @Autowired
    LikeService likeService;

    @PostMapping("/doCoursesLike")
    @ApiOperation(value="点赞or取消点赞", notes="根据用户id:uId,状态:status,父id:pId点赞", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name = "like",
                    value = "点赞实体类", required = true,
                    dataType = "com.jye.cloud.domain.Like"),
    })
    public JsonResult doCourseLike(  Like like){
        JsonResult jsonResult = new JsonResult();
        //类别复用
        int coursesType = MyConstants.likeType.coursesType;
        like.setType(coursesType);
        System.out.println(like);

        int i = likeService.doLike(like);
        if(i==1){
            jsonResult.setMsg("操作成功!");
        }else {
            jsonResult.setMsg("操作失败!");
        }
        return jsonResult;
    }



}
